<template>
  <div>
    <CommonModule
      v-bind="$attrs"
      showActionCol
      :columns="columns"
      :fetchList="fetchList"
      :actionRender="renderTableBtnAction"
    />
    <QualificationInfoDialog
      :visible.sync="qualificationInfo.visible"
      :uuid="qualificationInfo.uuid"
    />
  </div>
</template>
<script>
import CommonModule from './CommonModule';
import QualificationInfoDialog from '../../QualificationInfo';
import { QUALIFICATION_TYPE_COLUMNS } from './constants';
import { getTableAction } from '@/utils/getBtnsRender';
import { getQuaPrepareRecordDetailService } from '@/api/commodity/commodityAccessManage/commodityAdd';
export default {
  components: {
    CommonModule,
    QualificationInfoDialog
  },
  data () {
    return {
      columns: QUALIFICATION_TYPE_COLUMNS,
      qualificationInfo: { // 资质信息
        visible: false,
        uuid: ''
      },
    }
  },
  methods: {
    // 获取表格数据
    async fetchList (params, loadingFn) {
      const data = _.pick(params, ['recordNo'])
      const res = await getQuaPrepareRecordDetailService(data, loadingFn)
      return {
        results: res?.retData?.results ?? [],
        totalNum: res?.retData?.totalNum ?? 0,
      }
    },
    // 渲染表格操作栏按钮
    renderTableBtnAction (h, { row }) {
      const actionList = [{ label: '查看', method: this.handleToView }]
      return getTableAction({ h, row, actionList })
    },
    // 查看
    handleToView (row) {
      this.qualificationInfo.uuid = row.quaUuid
      this.qualificationInfo.visible = true
    }
  }
}
</script>
